//
// Created by Zhang on 2022/3/11.
//

#include <iostream>
#include <string>

#define PI 3.1415926535

//book q1
class Box {
private:
    double a;
    double b;
    double c;

public:
    Box(double x, double y, double z);

    double volume();

    double area();
};

double Box::volume() {
    return a * b * c;
}

double Box::area() {
    return 2 * (a * b + a * c + b * c);
}

Box::Box(double x, double y, double z) {

    a = x;
    b = y;
    c = z;
}

//book q2
class Time {
private:
    int hour{};
    int minutes{};
    int seconds{};

public:
    void show_time();

    void set_time(int, int, int);

    Time(int, int, int);

};

void Time::show_time() {
    std::cout << hour << ":" << minutes << ":" << seconds << std::endl;
}

void Time::set_time(int h, int m, int s) {
    if (s >= 60 || m >= 60) {
        std::cout << "out of range";
    }
    seconds = s;
    minutes = m;
    hour = h;
}

Time::Time(int h, int m, int s) {
    set_time(h, m, s);
}

//add q1
class Circle {
private:
    int radius;

public:
    float perimeter();

    float area();

    Circle(int);
};

float Circle::perimeter() {

    return float(radius) * 2 * PI;
}

float Circle::area() {
    return float(radius) * float(radius) * PI;
}

Circle::Circle(int r) {
    radius = r;
}


//add q2
class Student_Q1 {
private:
    std::string name;
    long id;
    int cpp;
    int english;
    int math;
public:
    void name_and_id();

    int sum();

    float average();

    Student_Q1(std::string nameS, long idS, int cppS, int englishS, int mathS);

};

void Student_Q1::name_and_id() {
    std::cout << "name:" << name << " id:" << id << std::endl;
}

int Student_Q1::sum() {

    return cpp + english + math;
}

float Student_Q1::average() {
    return float(sum() / 3.0);
}

Student_Q1::Student_Q1(std::string nameS, long idS, int cppS, int englishS, int mathS) {
    name = nameS;
    id = idS;
    cpp = cppS;
    english = englishS;
    math = mathS;
}


int main() {
    //book q1
    Box *a = new Box(1, 2, 3);
    std::cout << a->area() << std::endl << a->volume() << std::endl;
    delete a;
    //book q2
    Time *b = new Time(3, 5, 20);
    b->show_time();
    b->set_time(4, 12, 40);
    b->show_time();
    delete b;
    //add q1
    std::cout << "plz input radius of the pool:" << std::endl;
    int radius;
    std::cin >> radius;
    auto *pool = new Circle(radius);
    auto *path_out = new Circle(radius + 3);
    float path_cost = path_out->area() - pool->area();
    path_cost *= 20;
    float fan_cost = pool->perimeter() + path_out->perimeter();
    fan_cost *= 35;

    std::cout << "fan cost:" << fan_cost << " path cost:" << path_cost << std::endl;
    delete pool;
    delete path_out;
    //add q2
    auto *c = new Student_Q1("zzz", 9999999, 80, 71, 75);
    c->name_and_id();
    std::cout << "sum:" << c->sum() << " average:" << c->average() << std::endl;
    delete c;


    return 0;
}
